import { axios } from "../../utils/request";

const api = {
    PageList: "/crm/customer/page",
    pageForSelect: "/crm/customer/pageForSelect",
    pageForVoucher: "/crm/customer/pageForVoucher", //客户列表
    Save: "/crm/customer/save",
    receive: "/crm/customer/receive",//领用
    release: "/crm/customer/release",//释放
    dealSave: "/crm/customer/dealSave",//成交
    potentialSave: "/crm/customer/potentialSave",//退回
    saveShare: "/crm/customer/saveShare",// 分享
    distributionSave: "/crm/customer/distributionSave",// 分配
    disable: "/crm/customer/disable",// 停用
    enable: "/crm/customer/enable",// 启用
    collectAdd: "/crm/customer/collectAdd",// 收藏
    collectOut: "/crm/customer/collectOut",// 取消收藏
    combineSave: "/crm/customer/combineSave",//合并
    exportData: "/crm/customer/exportData",// 导出数据
    importTemplate: "/crm/customer/importTemplate",// 下载导入模版()
    getExcelFiled: "/crm/customer/getExcelFiled",// 获取Excel表头字段
    importData: "/crm/customer/importData",// 导入
    downloadFailCause: "/crm/customer/downloadFailCause", //下载失败原因
    detail: "/crm/customer/detail",

    deleteFinanceUrl: '/crm/customer/removeFromFinance',//财务往来单位删除
    distrivutorSaveUrl: '/crm/customer/saveVendor',//动态供应商保存
    distrivutorDeleteUrl: '/crm/customer/removeVendor',//动态供应商删除
    distrivetorImportUrl: '/crm/customer/importVendorData',//导入 供应商 数据
    distrivetorgetFiledUrl: '/crm/customer/getExcelFiledFromCompanyType',//获取供应商Excel表头字段
};

/**
 * 动态条件查询
 * @param {*} data
 */
export function PageList (data) {
    return axios({
        url: api.PageList,
        method: "post",
        data: data,
        timeout: 60000
    });
}

/**
 * 下拉搜索 客户
 * @param {*} data
 */
export function pageForSelect (data) {
    return axios({
        url: api.pageForSelect,
        method: "post",
        data: data
    });
}

/**
 * 客户列表
 * @param {*} data
 */
export function pageForVoucher (data) {
    return axios({
        url: api.pageForVoucher,
        method: "post",
        params: data
    });
}


export function getPageForVoucher (data) {
    return axios({
        url: api.pageForVoucher,
        method: "get",
        params: data
    });
}


/**
 * 保存客户
 */
export function Save (data) {
    return axios({
        url: api.Save,
        method: "post",
        data: data
    });
}

/**
 * 领用客户
 */
export function receive (data) {
    return axios({
        url: api.receive,
        method: "post",
        data: data
    });
}

/**
 * 释放客户
 */
export function release (data) {
    return axios({
        url: api.release,
        method: "post",
        data: data
    });
}

/**
 * 成交客户
 */
export function dealSave (data) {
    return axios({
        url: api.dealSave,
        method: "post",
        data: data
    });
}

/**
 * 退回客户
 */
export function potentialSave (data) {
    return axios({
        url: api.potentialSave,
        method: "post",
        data: data
    });
}

/**
 * 分享客户
 */
export function saveShare (data) {
    return axios({
        url: api.saveShare,
        method: "post",
        data: data,
        headers: {
            "Content-Type": "multipart/form-data"
        }
    });
}


/**
 * 分配客户
 */
export function distributionSave (data) {
    return axios({
        url: api.distributionSave,
        method: "get",
        params: data
    });
}

/**
 * 停用客户
 */
export function disable (data) {
    return axios({
        url: api.disable,
        method: "get",
        params: data
    });
}

/**
 * 启用客户
 */
export function enable (data) {
    return axios({
        url: api.enable,
        method: "get",
        params: data
    });
}

/**
 * 收藏客户
 */
export function collectAdd (data) {
    return axios({
        url: api.collectAdd,
        method: "post",
        data: data
    });
}

/**
 * 取消收藏客户
 */
export function collectOut (data) {
    return axios({
        url: api.collectOut,
        method: "post",
        data: data
    });
}

/**
 * 合并客户
 */
export function combineSave (data) {
    return axios({
        url: api.combineSave,
        method: "get",
        params: data
    });
}

/**
 * 导出客户
 */
export function exportData (data) {
    return axios({
        url: api.exportData,
        method: "post",
        data: data,
        responseType: 'blob',
        timeout: 60000
    });
}

/**
 * 下载导入模版
 */
export function importTemplate (data) {
    return axios({
        url: api.importTemplate,
        method: "get",
        params: data,
        responseType: 'blob'
    });
}

/**
 * 获取excel表头
 */
export function getExcelFiled (data) {
    return axios({
        url: api.getExcelFiled,
        method: "post",
        data: data,
        headers: {
            "Content-Type": "multipart/form-data"
        }
    });
}


/**
 * 获取供应商excel表头
 */
export function getDistrivetorExcelFiled (data) {
    return axios({
        url: api.distrivetorgetFiledUrl,
        method: "post",
        data: data,
        headers: {
            "Content-Type": "multipart/form-data"
        }
    });
}


/**
 * 导入客户
 */
export function importData (data) {
    return axios({
        url: api.importData,
        method: "post",
        data: data,
        headers: {
            "Content-Type": "multipart/form-data"
        },
        timeout: 5000000,
    });
}

/**
 * 下载失败原因和数据
 */
export function downloadFailCause (data) {
    return axios({
        url: api.downloadFailCause,
        method: "post",
        data: data,
        responseType: 'blob',
        headers: {
            "Content-Type": "multipart/form-data"
        },
        timeout: 60000,
    });
}

/**
 * 下载导入模版
 */
export function detail (data) {
    return axios({
        url: api.detail,
        method: "get",
        params: data,
    });
}

/**
 * 财务往来单位删除
 */
export function deleteFinanceApi (parameter) {
    return axios({
        url: api.deleteFinanceUrl,
        method: "delete",
        data: parameter
    });
}


/**
 * 动态供应商保存
 */
export function distrivutorSave (data) {
    return axios({
        url: api.distrivutorSaveUrl,
        method: "post",
        data: data
    });
}

/**
 * 财务往来单位删除
 */
export function distrivutorDelete (parameter) {
    return axios({
        url: api.distrivutorDeleteUrl,
        method: "delete",
        params: parameter
    });
}

/**
 * 导入供应商数据
 */
export function distrivetorImport (data) {
    return axios({
        url: api.distrivetorImportUrl,
        method: "post",
        data: data
    });
}

